// 支付链接类型
export interface LinkItem {
  id: string
  name: string
  productId: string
  productName: string
  productImage: string
  restaurantName?: string
  originalPrice: number
  discountPrice: number
  commission: number
  createdAt: string
  expiresAt: string
  status: 'active' | 'inactive'
  usageCount: number
  isActive: boolean
  url?: string
}

// 订单项类型 (经销商视角)
export interface OrderItem {
  id: string
  orderNumber: string
  productId?: string
  productName?: string
  productImage?: string
  originalPrice?: number
  discountPrice?: number
  quantity?: number
  totalAmount: number
  commission: number
  status: 'pending' | 'processing' | 'completed' | 'cancelled'
  payerName?: string
  createdAt: string
  paymentMethod?: string
  linkId?: string
  items?: any[]
  itemCount?: number
  restaurant?: {
    id: string
    name: string
    image?: string
  }
  customer?: any
  commissionRate?: string
  deliveryTime?: string | null
  comment?: string
  paymentLink?: {
    id: string
    name: string
  }
}

// 佣金记录类型
export interface CommissionRecord {
  id: string
  orderId: string
  orderNumber: string
  amount: number
  status: 'pending' | 'withdrawable' | 'withdrawn' | 'rejected'
  createdAt: string
  withdrawalDate: string | null
  remarks: string
}

// 产品类型 (经销商视角)
export interface Product {
  id: string
  name: string
  price: number
  minPrice?: number
  description: string
  category: string
  image: string
  rating: number
  reviewCount: number
  restaurant: {
    id: string
    name: string
  }
  isCustomerFavorite?: boolean
  isHot?: boolean
  currentDiscount?: number | null
  salesVolume?: number
  commissionRate?: string
  totalSales?: number
  totalCommission?: number
  status?: string
  discount?: number
  inventory?: number
  lastUpdated?: string
}

// 链接历史记录类型
export interface LinkHistoryRecord {
  id: string
  linkId: string
  customer: string
  paymentMethod: string
  amount: number
  time: string
  area: string
  orderNumber: string
  status: string
}

// 链接详情数据类型
export interface LinkDetail extends LinkItem {
  qrCodeUrl: string
  visits: number
  conversions: number
  conversionRate: number
  totalSales: number
  totalCommission: number
  historyRecords: LinkHistoryRecord[]
}

// 订单状态历史类型
export interface OrderStatusHistory {
  status: string
  label: string
  time: number
  description: string
}

// 订单详情数据类型
export interface OrderDetail {
  id: string
  orderNumber: string
  status: string
  customer: any
  restaurant: {
    id: string
    name: string
    image?: string
  }
  items: any[]
  totalAmount: number
  createdAt: string
  paymentInfo: {
    method: string
    transactionId: string
    paymentTime: number | null
    amount: number
    status: string
  }
  commissionCalculation: {
    originalTotal: number
    discountTotal: number
    discountAmount: number
    commissionRate: string
    commissionAmount: number
  }
  statusHistory: OrderStatusHistory[]
  paymentLink: {
    id: string
    name: string
  } | null
  address?: any
}

// 佣金明细数据类型
export interface CommissionDetail {
  id: string
  orderNumber: string
  productName: string
  productImage: string
  originalPrice: number
  discountPrice: number
  quantity: number
  salesAmount: number
  amount: number
  status: 'pending' | 'withdrawable' | 'withdrawn'
  createdAt: string
}

// 提现记录数据类型
export interface WithdrawalRecord {
  id: string
  applicationDate: string
  amount: number
  paymentMethod: string
  status: 'pending' | 'approved' | 'paid' | 'rejected'
  paymentDate: string | null
  rejectReason: string | null
}

// 用户资料数据类型
export interface UserProfile {
  name: string
  email: string
  phone: string
  bio: string
  avatar: string
  role: string
  joinDate: string
  lastLogin: string
  region: string
  verificationStatus: string
  twoFactorEnabled: boolean
} 